﻿using System;
using System.Diagnostics;
using System.IO;

namespace WhySoSeries
{
    static class DebugUtilities
    {
        public static void OpenInBrowser(Uri uri)
        {
            string content = WebUtilities.GetPageContent(uri.OriginalString);
            OpenInBrowser(content);
        }

        public static void OpenInBrowser(string content)
        {
            if (!Directory.Exists("DebugTests"))
                Directory.CreateDirectory("DebugTests");
            File.WriteAllText("DebugTests/test.html", content);
            Process.Start(Directory.GetCurrentDirectory() + "/DebugTests/test.html");
        }

        public static void OpenInNotepad(Uri uri)
        {
            string content = WebUtilities.GetPageContent(uri.OriginalString);
            OpenInBrowser(content);
        }

        public static void OpenInNotepad(string content)
        {
            if (!Directory.Exists("DebugTests"))
                Directory.CreateDirectory("DebugTests");
            File.WriteAllText("DebugTests/test.txt", content);
            Process.Start(Directory.GetCurrentDirectory() + "/DebugTests/test.txt");
        }
    }
}
